package com.think.archive.util;

import com.think.archive.dto.SysUserDto;
import com.think.archive.model.SysUser;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;

import java.util.ArrayList;
import java.util.List;

public class OrikaUtil {

    public static SysUserDto transUserToDto(SysUser user){
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        SysUserDto userDto = mapperFactory.getMapperFacade().map(user, SysUserDto.class);
        return userDto;
    }

    public static List<SysUserDto> transUserToDtos(List<SysUser> users){
        List<SysUserDto> userDtos=new ArrayList<>();
        for(SysUser user:users){
            SysUserDto userDto=transUserToDto(user);
            userDtos.add(userDto);
        }
        return userDtos;
    }

}
